package dto

import (
	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type ClusterGetPageReq struct {
	dto.Pagination `search:"-"`
	ClusterOrder
}

type ClusterOrder struct {
	Id         string `form:"idOrder"  search:"type:order;column:id;table:cluster"`
	Name       string `form:"nameOrder"  search:"type:order;column:name;table:cluster"`
	Credential string `form:"credentialOrder"  search:"type:order;column:credential;table:cluster"`
	Remark     string `form:"remarkOrder"  search:"type:order;column:remark;table:cluster"`
	CreatedAt  string `form:"createdAtOrder"  search:"type:order;column:created_at;table:cluster"`
	UpdatedAt  string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:cluster"`
	DeletedAt  string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:cluster"`
	CreateBy   string `form:"createByOrder"  search:"type:order;column:create_by;table:cluster"`
	UpdateBy   string `form:"updateByOrder"  search:"type:order;column:update_by;table:cluster"`
}

func (m *ClusterGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type ClusterInsertReq struct {
	Id         int    `json:"-" comment:"编码"` // 编码
	Name       string `json:"name" comment:"名称"`
	Credential string `json:"credential" comment:"凭据"`
	Remark     string `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *ClusterInsertReq) Generate(model *models.Cluster) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Name = s.Name
	model.Credential = s.Credential
	model.Remark = s.Remark
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *ClusterInsertReq) GetId() interface{} {
	return s.Id
}

type ClusterUpdateReq struct {
	Id         int    `uri:"id" comment:"编码"` // 编码
	Name       string `json:"name" comment:"名称"`
	Credential string `json:"-" comment:"凭据"`
	Remark     string `json:"remark" comment:"备注"`
	common.ControlBy
}

func (s *ClusterUpdateReq) Generate(model *models.Cluster) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Name = s.Name
	model.Credential = s.Credential
	model.Remark = s.Remark
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *ClusterUpdateReq) GetId() interface{} {
	return s.Id
}

// ClusterGetReq 功能获取请求参数
type ClusterGetReq struct {
	Id int `uri:"id"`
}

func (s *ClusterGetReq) GetId() interface{} {
	return s.Id
}

// ClusterDeleteReq 功能删除请求参数
type ClusterDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *ClusterDeleteReq) GetId() interface{} {
	return s.Ids
}
